package com.sky.controller.admin;

import com.github.pagehelper.PageHelper;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderStatisticsVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
@Slf4j
@Api(tags = "商家端订单接口")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 商家端分页条件查询
     * @param ordersPageQueryDTO
     * @return
     */
    @GetMapping("/conditionSearch")
    @ApiOperation(value = "商家端分页条件查询")
    public Result<PageResult> pageListOrder(OrdersPageQueryDTO ordersPageQueryDTO) {

        PageResult pageResult = orderService.pageListOrder(ordersPageQueryDTO);

        return Result.success(pageResult);
    }

    /**
     * 统计各个状态的订单数量
     * @return
     */
    @GetMapping("/statistics")
    @ApiOperation(value = "统计各个状态订单的数量")
    public Result<OrderStatisticsVO> orderStatistics() {

        OrderStatisticsVO orderStatisticsVO = orderService.orderStatistics();

        return Result.success(orderStatisticsVO);
    }

    @PutMapping("/confirm")
    @ApiOperation(value = "商家接单操作")
    public Result<String> confirmOrder(@RequestBody OrdersConfirmDTO ordersConfirmDTO) {
        log.info("[商家接单]{}", ordersConfirmDTO);



        return Result.success("接单成功");
    }
}
